<template>
  <div class="page-content-base">
    <div class="page-content-title">
     <div class="page-content-title-search">
        <a-space>
          <a-button type="primary" @click="ClickBack" v-show="showFenPei==true">返回管理界面</a-button>
          <a-button type="primary" @click="ClickSearch">查询</a-button>
       </a-space>
      </div>
      <h3 class="page-content-title-name">任务管理</h3>
    </div>
    <div class="page-content-forms">
      <a-space>
        <div>
          <label>任务ID：</label>
          <a-input placeholder="like 15010320202401" style="width: 200px"   @change="onChangeMergeid" v-model="mergeid" allowClear   size="small"/>
        </div>
        <div v-show="showFenPei==false">
          <label>任务状态：</label>
          <a-select style="width: 120px" @change="task_status_change" allowClear v-model="task_status"   size="small">
            <a-select-option :value="item.status" v-for="(item,index) in $store.state.task_status" :key="index" >{{item.name}}</a-select-option>
          </a-select>
        </div>
        <div v-show="showFenPei==false">
          <label>任务类型：</label>
          <a-select style="width: 220px" @change="task_type_Change"  v-model="manager_task_type"  size="small">
            <a-select-option :value="item.type" v-for="(item,index) in $store.state.task_types" :key="index" >{{item.name}}</a-select-option>
          </a-select>
        </div>
        <div v-show="showFenPei==true">
          <label>实施小组：</label>
          <a-select style="width: 160px" @change="orgSelectChange" allowClear v-model="org" option-label-prop="label"   size="small">
            <a-select-option :value="item.id" :label="item.name" v-for="(item,index) in $store.state.orgs" :key="index">{{item.name}}</a-select-option>
          </a-select>
        </div>
        <div v-show="showFenPei==true">
          <label>实施角色：</label>
          <a-select style="width: 160px" @change="roleSelectChange" allowClear v-model="role" option-label-prop="label"   size="small">
            <a-select-option :value="item.id" :label="item.name" v-for="(item,index) in $store.state.roles" :key="index">{{item.name}}</a-select-option>
          </a-select>
        </div>
        <div v-show="showFenPei==true">
          <label>实施人员：</label>
          <a-select style="width: 140px" @change="NameSelectChange" allowClear v-model="detail_form.name"   size="small">
            <a-select-option :value="item.fullname" v-for="(item,index) in getActiveUsers" :key="index">{{item.fullname}}</a-select-option>
          </a-select>
        </div>
        <div v-show="showFenPei==true">
          <label>选定流程：</label>
          <a-select style="width: 120px" @change="workSelectChange"  v-model="work_type"   size="small">
            <a-select-option :value="item.type" v-for="(item,index) in $store.state.bigdata_sample_works" :key="index">{{item.name}}</a-select-option>
          </a-select>
        </div>
        <div v-show="showFenPei==true">
          <label>图斑状态：</label>
          <a-select style="width: 320px" @change="detail_status_change" allowClear v-model="detail_form.status" v-show="work_type=='change'"   size="small">
            <a-select-option :value="item.status" v-for="(item,index) in $store.state.detail_status" :key="index" :disabled="item.disabled">{{item.name}}</a-select-option>
          </a-select>
          <a-select style="width: 320px" @change="detail_status_change" allowClear v-model="detail_form.status" v-show="work_type=='changecheck'||work_type=='editcheck'"   size="small">
            <a-select-option :value="-2" >未实施</a-select-option>
            <a-select-option :value="1" >正确</a-select-option>
            <a-select-option :value="2" >错误</a-select-option>
          </a-select>
          <a-select style="width: 320px" @change="detail_status_change" allowClear v-model="detail_form.status" v-show="work_type=='edit'"   size="small">
            <a-select-option :value="-2" >未实施</a-select-option>
            <a-select-option :value="1" >未编辑</a-select-option>
            <a-select-option :value="2" >已编辑</a-select-option>
          </a-select>
        </div>
        <div class="page-content-title-search" v-show="showFenPei==true && can_fenpei==true">
          <a-space>
              <a-button type="primary" @click="mulity_fenpei" v-show="can_fenpei">勾选分配</a-button>
              <a-button type="primary" @click="input_fenpei" v-show="can_fenpei">输入分配</a-button>
          </a-space>
        </div>
       </a-space>
    </div>
    <div class="page-content-table task-show-simple" v-show="(manager_task_type=='bigdata'||manager_task_type=='sample') && showFenPei==false">
      <a-table 
      :columns="task_show_simple_columns" 
      :data-source="task_show_simple_data" 
      bordered 
      :pagination="task_show_simple_pagination"  
      size="small" 
      :customRow="task_show_simple_RowEvents" 
      @change="task_show_simple_pagination_change"
      >
       <span slot="mergeid" slot-scope="text, record"> 
          <span class="menu-name" style="user-select: text;">{{record.mergeid}}</span>
        </span>
        <span slot="task_type" slot-scope="text, record"> 
          <span class="menu-name">{{manager_type_name}}</span>
        </span>
        
        <span slot="utime" slot-scope="text, record"> 
          <span class="menu-name">{{GetTime(record.utime)}}</span>
        </span>
        <span slot="num" slot-scope="text, record"> 
          <span class="menu-name">{{record.num}}</span>
        </span>
        <span slot="stime" slot-scope="text, record"> 
          <span class="menu-name">{{GetTaskTime(record[manager_task_type],"stime")}}</span>
        </span>
        <span slot="etime" slot-scope="text, record"> 
          <span class="menu-name">{{GetTaskTime(record[manager_task_type],"etime")}}</span>
        </span>
        <span slot="status" slot-scope="text, record"> 
          <a-badge :color="Get_task_show_simple_StatusColor(record)" :text="Get_task_show_simple_StatusText(record)" />
        </span>
        <span slot="process" slot-scope="text, record">
          <a-progress :percent="record.process" />
        </span>
        <span slot="operation" slot-scope="text, record">
          <a-dropdown :trigger="['click']">
                <p class="header-right-name ant-dropdown-trigger" @click="dropdown_click"  style="cursor: pointer;">操作</p>
                <a-menu slot="overlay" mode="inline">
                  <a-sub-menu key="sub1">
                    <span slot="title">
                      <a-icon type="appstore" />
                      <span>任务状态管理</span>
                    </span>
                    <a-menu-item >
                      <a-button type="link"  @click="set_task_show_simple_status(record)">设定任务状态</a-button>
                    </a-menu-item>
                    <a-menu-item>
                      <a-button type="link" @click="task_show_simple_delete(record)">删除任务</a-button>
                    </a-menu-item>
                  </a-sub-menu>
                  <a-sub-menu key="sub2">
                    <span slot="title">
                      <a-icon type="appstore" />
                      <span>内业判定变化检查</span>
                    </span>
                    <a-menu-item >
                    <!-- :disabled="!(record[$store.state.task_type].status>=1)" -->
                      <a-button type="link"   @click="CheckType(record.mergeid,2)">对代码为2(内业判定变化图斑)的进行检查 </a-button>
                      <a-tooltip placement="bottom" style="margin-left: 5px;" @click="tooltip_click()">
                        <template slot="title"><span>对进行人工判译后的代码为2(内业判定变化图斑)进行检查并更新(如果是多次检查则后续检查会覆盖上次结果)</span></template>
                        <a-icon type="question-circle" />
                      </a-tooltip>
                    </a-menu-item>
                    <a-menu-item>
                    <a-button type="link" :disabled="amqp_2_num==0" @click="checker_back_to_amqp(record.mergeid,5)">未完成任务返回消息队列</a-button>
                      <a-tooltip placement="bottom" style="margin-left: 5px;">
                        <template slot="title"><span>将该检查中未完成的任务并返回队列!</span></template>
                        <a-icon type="question-circle" />
                      </a-tooltip>
                    </a-menu-item>
                  </a-sub-menu>
                 <a-sub-menu key="sub3">
                    <span slot="title">
                      <a-icon type="appstore" />
                      <span>人工属性分类检查</span>
                    </span>
                    <a-menu-item >
                      <a-button type="link"   @click="CheckType(record.mergeid,5)">对代码为5的进行赋值并检查</a-button>
                      <a-tooltip placement="bottom" style="margin-left: 5px;" @visibleChange="tooltip_visibleChange($event,record.mergeid,5)" >
                        <template slot="title"><span>对进行判译后的代码为5(内业、外业判定变化图斑)进行赋值并更新(如果是多次检查则后续检查会覆盖上次结果) {{amqp_num}}/{{amqp_task_num}}</span></template>
                        <a-icon type="question-circle" />
                      </a-tooltip>
                    </a-menu-item>
                    <a-menu-item>
                      <a-popconfirm title="谨慎操作!确定要将未完成任务返回消息队列吗?" @confirm="checker_back_to_amqp(record.mergeid,5)">
                        <a-icon slot="icon" type="question-circle-o" style="color: red" />
                        <a-button type="link" :disabled="amqp_2_num==0" >未完成任务返回消息队列222</a-button>
                        <a-tooltip placement="bottom" style="margin-left: 5px;">
                          <template slot="title"><span>将该检查中未完成的任务并返回队列!</span></template>
                          <a-icon type="question-circle" />
                        </a-tooltip>
                      </a-popconfirm>
                    </a-menu-item>
                   

                     <a-menu-item >
                      <a-button type="link"   @click="CheckType(record.mergeid,6)">对代码为6的进行赋值并检查</a-button>
                      <a-tooltip placement="bottom" style="margin-left: 5px;" @click="tooltip_click()">
                        <template slot="title"><span>对进行判译后的代码为5(内业、外业判定变化图斑)进行赋值并更新(如果是多次检查则后续检查会覆盖上次结果)</span></template>
                        <a-icon type="question-circle" />
                      </a-tooltip>
                    </a-menu-item>
                  </a-sub-menu>

                  
                  <a-sub-menu key="sub4" v-show="manager_task_type!='jdcheck'">
                    <span slot="title">
                      <a-icon type="appstore" />
                      <span>人工图形勾绘</span>
                    </span>
                    <a-menu-item >
                      <a-button type="link"   @click="CheckType(record.mergeid,7)">对代码为6的进行勾绘</a-button>
                      <a-tooltip placement="bottom" style="margin-left: 5px;" @visibleChange="tooltip_visibleChange($event,record.mergeid,7)" >
                        <template slot="title"><span>对属性分类后代码为6的图斑进行准确勾绘 {{amqp_num}}/{{amqp_task_num}}</span></template>
                        <a-icon type="question-circle" />
                      </a-tooltip>
                    </a-menu-item>
                    <a-menu-item>
                      <a-popconfirm title="谨慎操作!确定要将未完成任务返回消息队列吗?" @confirm="checker_back_to_amqp(record.mergeid,7)">
                        <a-icon slot="icon" type="question-circle-o" style="color: red" />
                        <a-button type="link" >未完成任务返回消息队列</a-button>
                        <a-tooltip placement="bottom" style="margin-left: 5px;">
                          <template slot="title"><span>将未完成的勾绘任务返回队列!</span></template>
                          <a-icon type="question-circle" />
                        </a-tooltip>
                      </a-popconfirm>
                    </a-menu-item>
                  </a-sub-menu>


                  <a-menu-item >
                    <a-button type="link"  @click="FenPei(record)">任务分配</a-button>
                  </a-menu-item>
                  <a-menu-item >
                    <a-button type="link"  @click="show(record.mergeid)">查看</a-button>
                  </a-menu-item>
                   <a-menu-item  >
                    <a-button type="link"  @click="DownTask(record.mergeid)">任务结果下载</a-button>
                  </a-menu-item>
                </a-menu>
            </a-dropdown>
        </span>
      </a-table>
    </div>
    <div class="page-content-table tasks_check" v-show="manager_task_type=='jdcheck' && showFenPei==false">
      <a-table 
      :columns="tasks_check_column" 
      :data-source="tasks_check_data" 
      bordered 
      :pagination="tasks_check_pagination"
      size="small" 
      @change="tasks_check_pagination_change"
      >
        <span slot="mergeid" slot-scope="text, record"> 
          <span class="menu-name" style="user-select: text;">{{record.mergeid}}</span>
        </span>
        <span slot="task_type" slot-scope="text, record"> 
          <span class="menu-name">{{manager_type_name}}</span>
        </span>
        <span slot="utime" slot-scope="text, record"> 
          <span class="menu-name">{{GetTime(record.utime)}}</span>
        </span>
        <span slot="num" slot-scope="text, record"> 
          <span class="menu-name">{{record.num}}</span>
        </span>
        <span slot="worker" slot-scope="text, record"> 
          <span class="menu-name">{{record.jdcheck.name}}</span>
        </span>
        
        <span slot="stime" slot-scope="text, record"> 
          <span class="menu-name">{{GetTaskTime(record[manager_task_type],"stime")}}</span>
        </span>
        <span slot="etime" slot-scope="text, record"> 
          <span class="menu-name">{{GetTaskTime(record[manager_task_type],"etime")}}</span>
        </span>
        <span slot="status" slot-scope="text, record"> 
          <a-badge :color="Get_task_show_simple_StatusColor(record)" :text="Get_task_show_simple_StatusText(record)" />
        </span>
        <span slot="process" slot-scope="text, record">
          <a-progress :percent="record.process" />
        </span>
      </a-table>
    </div>
    <div class="page-content-table taskdetals-show-simple" v-show="(manager_task_type=='bigdata'||manager_task_type=='sample') && showFenPei==true">
      <a-table 
      :columns="taskdetals_show_simple_columns" 
      :data-source="taskdetals_show_simple_data" 
      bordered 
      :pagination="taskdetals_show_simple_pagination"  
      size="small"
      @change="taskdetals_show_simple_pagination_change"
      :row-selection="{ selectedRowKeys: taskdetals_show_simple_selectedRowKeys, onChange: taskdetals_show_simple_selectkeys_change }"
      >
        <p slot="expandedRowRender" slot-scope="record" style="margin: 0">
          <a-descriptions bordered="true" size="small" :column="4"> 
            <a-descriptions-item label="前时相">{{record.properties.other.QSX}}</a-descriptions-item>
            <a-descriptions-item label="前影像" >{{record.properties.other.QQJH}}</a-descriptions-item>
            <a-descriptions-item label="后时相">{{record.properties.other.HSX}}</a-descriptions-item>
            <a-descriptions-item label="后影像" >{{record.properties.other.DQJH}}</a-descriptions-item>

            <a-descriptions-item label="行政区划代码">{{record.properties.other.XZQDM}}</a-descriptions-item>
            <a-descriptions-item label="行政区划名称">{{record.properties.other.XMC}}</a-descriptions-item>
            <a-descriptions-item label="变化图斑编号" :span="2">{{record.properties.other.JVBH}}</a-descriptions-item>


            <a-descriptions-item label="变化判别">NUll</a-descriptions-item>
            <a-descriptions-item label="判别人员">{{record.properties[manager_task_type].change.name}}</a-descriptions-item>
            <a-descriptions-item label="判别状态" >{{Get_taskdetals_status_color_status(record,"change")}}</a-descriptions-item>
            <a-descriptions-item label="判别时间" >{{GetTime(record.properties[manager_task_type].change.time)}}</a-descriptions-item>

            <a-descriptions-item label="变化判别检查">NUll</a-descriptions-item>
            <a-descriptions-item label="判别检查人员">{{record.properties[manager_task_type].changecheck.name}}</a-descriptions-item>
            <a-descriptions-item label="判别检查状态" >{{record.properties[manager_task_type].changecheck.status==-2?"未实施":record.properties[manager_task_type].changecheck.status==1?"正确":"错误"}}</a-descriptions-item>
            <a-descriptions-item label="判别检查时间" >{{GetTime(record.properties[manager_task_type].changecheck.time)}}</a-descriptions-item>


            <a-descriptions-item label="图形编辑">NUll</a-descriptions-item>
            <a-descriptions-item label="图形编辑人员">{{record.properties[manager_task_type].edit.name}}</a-descriptions-item>
            <a-descriptions-item label="图形编辑状态" >{{record.properties[manager_task_type].changecheck.status==-2?"未实施":record.properties[manager_task_type].changecheck.status==1?"未编辑":"已编辑"}}</a-descriptions-item>
            <a-descriptions-item label="图形编辑时间" >{{GetTime(record.properties[manager_task_type].edit.time)}}</a-descriptions-item>


            <a-descriptions-item label="图形编辑检查">NUll</a-descriptions-item>
            <a-descriptions-item label="图形编辑人员">{{record.properties[manager_task_type].editcheck.name}}</a-descriptions-item>
            <a-descriptions-item label="图形编辑状态" >{{record.properties[manager_task_type].changecheck.status==-2?"未实施":record.properties[manager_task_type].changecheck.status==1?"正确":"错误"}}</a-descriptions-item>
            <a-descriptions-item label="图形编辑时间" >{{GetTime(record.properties[manager_task_type].editcheck.time)}}</a-descriptions-item>
          </a-descriptions>
        </p>
        <span slot="taskid" slot-scope="text, record"> 
          <span class="menu-name"  style="user-select: text;">{{record.properties.taskid}}</span>
        </span>
        <span slot="code" slot-scope="text, record"> 
          <span class="menu-name"  style="user-select: text;">{{record.properties.other.JVBH}}</span>
        </span>
        <span slot="type" slot-scope="text, record">
          <span class="menu-name" >{{$common_apis.Get_work_type_name(work_type)}}</span>
        </span>
        <span slot="name" slot-scope="text, record">
          <span class="menu-name" >{{record.properties[manager_task_type][work_type].name}}</span>
        </span>
        <span slot="preimage" slot-scope="text, record"> 
          <div class="showimg" style="width: 30px;height: 30px;position: relative;">
              <img :src="Get_img(record.properties.preimage)" style="width: 100%;height: 100%;"/>
              <div class="demo-upload-list-cover" style="width: 100%;height: 100%;">
                <a-icon type="eye"  title="预览" @click.native="handleView(Get_img(record.properties.preimage),mergeid,record.properties.taskid,record.properties.other.JVBH)"/>
              </div>
          </div>
        </span>
        <span slot="lstimage" slot-scope="text, record"> 
          <div class="showimg" style="width: 30px;height: 30px;position: relative;">
              <img :src="Get_img(record.properties.lstimage)" style="width: 100%;height: 100%;"/>
              <div class="demo-upload-list-cover" style="width: 100%;height: 100%;">
                <a-icon type="eye"  title="预览" @click.native="handleView(Get_img(record.properties.lstimage),mergeid,record.properties.taskid,record.properties.other.JVBH)"/>
              </div>
          </div>
        </span>
        <span slot="time" slot-scope="text, record"> 
          <span class="menu-name">{{GetTime(record.properties[manager_task_type][work_type].time)}}</span>
        </span>
        <span slot="status" slot-scope="text, record"> 
          <a-badge v-show="work_type=='change'" :color="Get_taskdetals_status_color(record.properties[manager_task_type][work_type].status)" :text="Get_taskdetals_status_color_status(record,'change')" />
          <a-badge v-show="work_type=='changecheck'" :color="Get_taskdetals_status_check_color(record.properties[manager_task_type][work_type].status)" :text="record.properties[manager_task_type][work_type].status==-2?'未实施':record.properties[manager_task_type][work_type].status==1?'正确':'错误'" />
          <a-badge v-show="work_type=='edit'" :color="Get_taskdetals_status_edit_color(record.properties[manager_task_type][work_type].status)" :text="record.properties[manager_task_type][work_type].status==-2?'未实施':record.properties[manager_task_type][work_type].status==1?'未编辑':'已编辑'" />
          <a-badge v-show="work_type=='editcheck'" :color="Get_taskdetals_status_check_color(record.properties[manager_task_type][work_type].status)" :text="record.properties[manager_task_type][work_type].status==-2?'未实施':record.properties[manager_task_type][work_type].status==1?'正确':'错误'" />
          <!-- <a-badge v-show="work_type=='prop'" :color="GetEDITstatus(record.properties[manager_task_type][work_type].status)" :text="record.properties[manager_task_type][work_type].status==-2?'未实施':record.properties[manager_task_type][work_type].status==1?'未编辑':'已编辑'" />
          <a-badge v-show="work_type=='propcheck'" :color="Get_taskdetals_status_check_color(record.properties[manager_task_type][work_type].status)" :text="record.properties[manager_task_type][work_type].status==-2?'未实施':record.properties[manager_task_type][work_type].status==1?'正确':'错误'" /> -->
        </span>
        <span slot="operation" slot-scope="text, record">
          <a-space>
            <a-button class="operation-a" type="link"  @click="single_fenpei(record['_id'],record.properties.other.JVBH)"  v-show="can_fenpei">分配</a-button>
            <a-button class="operation-a" type="link"  @click="ShowModel(record)">预览</a-button>
          </a-space>
          
        </span>
      </a-table>
    </div>
    <a-modal v-model="pic_view_visible" :title="pic_name" 
      :maskClosable="false"
      okText="确定"
      okType="dashed"
      :destroyOnClose="true"
      cancelText='取消'
      cancelokType="dashed"
      width="40%"
      >
      <img :src="pic_imgsrc" v-if="pic_view_visible" style="width: 100%">
    </a-modal>
    <a-drawer class="map_drawer"
      :title="drawer_title"
      placement="right"
      :visible="map_visible"
      @close="closeModel"
      width="70%">
      <show_png></show_png>
    </a-drawer>
    <set_task_status/>
    <fen_to_user/>

    
  </div>
</template>
<script>
export default {
  data() {
    return {
      mergeid:'',//输入
      task_status:'',//输入

      manager_task_type:'bigdata',
      manager_type_name:'执法服务',

      showFenPei:false,//控制变量
      can_fenpei:false,//控制变量
      ///
      task_show_simple_data:[],
      task_show_simple_columns:[
          {
              title: '任务名称',
              dataIndex: 'name',
              width:250,
              align:'center'
          },
          {
              title: '任务ID',
              scopedSlots: { customRender: 'mergeid' } ,
              width:270,
              align:'center',

          },
          {
              title: '任务类型',
              scopedSlots: { customRender: 'task_type' } ,
              width:100,
              align:'center',

          },
          {
              title: '上传时间',
              scopedSlots: { customRender: 'utime' } ,
              width:170,
              align:'center'
          },
          {
              title: '数量',
              scopedSlots: { customRender: 'num' } ,
              width:100,
              align:'center'
          },
          {
              title: '开始时间',
              scopedSlots: { customRender: 'stime' } ,
              width:170,
              align:'center'
          },
          {
              title: '结束时间',
              scopedSlots: { customRender: 'etime' } ,
              width:170,
              align:'center'
          },
          {
              title: '状态',
              scopedSlots: { customRender: 'status' } ,
              width:140,
              align:'center'
          },
          {
              title: '进度',
              scopedSlots: { customRender: 'process' } ,
              width:280,
              align:'center'
          },
          {
            title: '操作',
            scopedSlots: { customRender: 'operation' },
            align:'center'
          },
      ],
      task_show_simple_pagination:{
        size:'small',
        pageSize:15,
        total:0,
        showTotal:(total, range)=>{
          return `共 ${total} 个，当前${range[0]}-${range[1]}`
        },
      },
      task_show_simple_RowEvents: record => ({
        on: {
          dblclick: () => {
            this.can_fenpei=false
            this.showFenPei=true;
            this.mergeid=record.mergeid
            this.ClickSearch()
          },
        }
      }),

      ///
      tasks_check_data:[],
      tasks_check_column:[
          {
              title: '任务ID',
              scopedSlots: { customRender: 'mergeid' } ,
              width:270,
              align:'center',

          },
          {
              title: '任务类型',
              scopedSlots: { customRender: 'task_type' } ,
              width:100,
              align:'center',

          },
          {
              title: '上传时间',
              scopedSlots: { customRender: 'utime' } ,
              width:170,
              align:'center'
          },
          {
              title: '数量',
              scopedSlots: { customRender: 'num' } ,
              width:100,
              align:'center'
          },
          {
              title: '操作人',
              scopedSlots: { customRender: 'worker' } ,
              width:100,
              align:'center'
          },
          {
              title: '开始时间',
              scopedSlots: { customRender: 'stime' } ,
              width:170,
              align:'center'
          },
          {
              title: '结束时间',
              scopedSlots: { customRender: 'etime' } ,
              width:170,
              align:'center'
          },
          {
              title: '状态',
              scopedSlots: { customRender: 'status' } ,
              width:140,
              align:'center'
          },
          {
              title: '进度',
              scopedSlots: { customRender: 'process' } ,
              width:280,
              align:'center'
          },
          {
            title: '操作',
            scopedSlots: { customRender: 'operation' },
            align:'center'
          },
      ],
      tasks_check_pagination:{
        size:'small',
        pageSize:15,
        total:0,
        showTotal:(total, range)=>{
          return `共 ${total} 个，当前${range[0]}-${range[1]}`
        },
      },
      ///
      taskdetals_show_simple_data:[],
      taskdetals_show_simple_columns:[
        {
            title: 'AI编号',
            scopedSlots: { customRender: 'taskid' },
            key: 'code',
            width:310,
            align:'center'
        },
        {
            title: '图斑编号',
            scopedSlots: { customRender: 'code' },
            key: 'code',
            width:260,
            align:'center'
        },
        {
          title: '流程',
          scopedSlots: { customRender: 'type' },
          width:140,
          align:'center'
        },
        
        {
            title: '实施人员',
            scopedSlots: { customRender: 'name' },
            width:140,
            align:'center'
        },
        {
            title: '前一期影像',
            scopedSlots: { customRender: 'preimage' } ,
            width:130,
            align:'center'
        },
        {
            title: '后一期影像',
            scopedSlots: { customRender: 'lstimage' } ,
            width:130,
            align:'center'
        },
        {
            title: '状态',
            scopedSlots: { customRender: 'status' } ,
            width:250,
            align:'center'
        },
        {
            title: '解译时间',
            scopedSlots: { customRender: 'time' } ,
            width:210,
            align:'center'
        },
        {
          title: '操作',
          scopedSlots: { customRender: 'operation' },
          align:'center'
        },
      ],
      taskdetals_show_simple_pagination:{
        size:'small',
        pageSize:10,
        total:0,
        showTotal:(total, range)=>{
          return `共 ${total} 个，当前${range[0]}-${range[1]}`
        },
      },
      taskdetals_show_simple_selectedRowKeys:[],

      org:undefined,
      role:undefined,
      work_type:"change",
      detail_form:{
        code:'',
        name:'',//分配的用户
        status:'',//，每个图斑的状态
        taskid:''
      },
      pic_view_visible:false,
      pic_imgsrc:'',
      pic_name:'',

      map_visible:false,
      drawer_title:"",
      


      

      


         


      
      
      
      //外部传入
      columns:[
        {
            title: 'AI编号',
            scopedSlots: { customRender: 'taskid' },
            key: 'code',
            width:310,
            align:'center'
        },
        {
            title: '图斑编号',
            scopedSlots: { customRender: 'code' },
            key: 'code',
            width:260,
            align:'center'
        },
        {
            title: '实施人员',
            scopedSlots: { customRender: 'name' },
            width:140,
            align:'center'
        },
        {
            title: '前一期影像',
            scopedSlots: { customRender: 'preimage' } ,
            width:130,
            align:'center'
        },
        {
            title: '后一期影像',
            scopedSlots: { customRender: 'lstimage' } ,
            width:130,
            align:'center'
        },
        {
            title: '状态',
            scopedSlots: { customRender: 'status' } ,
            width:250,
            align:'center'
        },
        {
            title: '解译时间',
            scopedSlots: { customRender: 'time' } ,
            width:210,
            align:'center'
        },
        {
          title: '操作',
          scopedSlots: { customRender: 'operation' },
          align:'center'
        },
      ],
      task_one_table_data:[],
      task_one_pagination:{
        size:'small',
        pageSize:10,
        total:0,
        showTotal:(total, range)=>{
          return `共 ${total} 个，当前${range[0]}-${range[1]}`
        },
      },
      
      fenpei_visible:false,
      fenpei_name:'',
      codes:[],


      

      fenpei_in_visible:false,
      num_from:'',
      num_to:'',
      
      



      
      
      amqp_num:0,
      amqp_task_num:0,
    }
  },
  components: {
    show_png: () => import("@/components/router/show_png.vue"),
    set_task_status: () => import("./set_task_status.vue"),
    fen_to_user: () => import("./fen_to_user.vue"),

    
  },
  mounted() {
    this.$mitt.$on('set_status_back', (vals) => {
      if(vals.type=="task_show_simple"){
        this.set_task_show_simple_status_back(vals)
      }
    });
    this.$mitt.$on('fenpei_to_user_back', (vals) => {
      this.fenpei_update(vals)
    });
  },
  beforeDestroy() {
    this.$mitt.$off('set_status_back');
    this.$mitt.$off('fenpei_to_user_back');
  },
  computed:{
    getActiveUsers(){
        return this.$store.state.users
      }
    },
  // watch: {
  //   '$store.state.task_type':function(){
  //     this.search(1);
  //   },
  // },
  methods: {
    ClickBack(){
      this.can_fenpei=false
      this.showFenPei=false;
      this.searchTask(1);
    },
    ClickSearch(){
      if(this.showFenPei){
        this.searchTaskDetails(1);
      }
      else{
        this.searchTask(1);
      }
    },
    onChangeMergeid(){
      if(this.mergeid==""){
        this.ClickBack()
      }
    },
    task_status_change(){
      this.ClickBack();
    },
    task_type_Change(value, option){
      this.manager_type_name=this.$common_apis.Get_task_type_name(value)
      this.ClickBack();
    },
    async searchTask(pagenum){
      this.table_data=[]
      let qs={
        pagesize:this.task_show_simple_pagination.pageSize,
        pagenum,
        optype:this.manager_task_type
      }
      let status=this.task_status===""?-3:this.task_status-0
      if(status>=-2){
        qs.status=this.task_status
      }
      let result=await this.$common_apis.axios_get("/search_task?",qs)
      if(result){
        let table_data=result.data
        table_data.forEach((_featrue,index)=>{
          _featrue.process=0
          _featrue.key=index
        })
        if(this.manager_task_type=='bigdata'||this.manager_task_type=='sample'){
          this.task_show_simple_data=table_data
          this.task_show_simple_pagination.total=result.page.count
          //this.search_process();
        }
        else{
          this.tasks_check_data=table_data
          this.task_one_pagination.total=result.page.count
        }
      }
    },
    task_show_simple_pagination_change(pagination){
      this.task_show_simple_pagination.ucurrent=pagination.current
      this.searchTask(pagination.current)
    },
    tasks_check_pagination_change(pagination){
      this.searchTask(pagination.current)
    },
    Get_task_show_simple_StatusText(record){
      let _val=record[this.manager_task_type]?.status
      return this.GetStatusText_fun(_val)
    },
    GetStatusText_fun(status){
      let status_index= this.$store.state.task_status.findIndex((_task_status)=>{
        return _task_status.status==status
      })
      return status_index>=0?this.$store.state.task_status[status_index].name:""
    },
    Get_task_show_simple_StatusColor(record){
      let _val=record[this.manager_task_type]?.status
      return this.GetStatusColor_func(_val)
    },
    GetStatusColor_func(status){
      let status_Color="";
      if(status==-2){
        status_Color="red"
      }
      else if(status==-1){
        status_Color="gray"
      }
      else if(status==0){
        status_Color="blue"
      }
      else if(status>=1){
        status_Color="green"
      }
      else{
        status_Color="red"
      }
      return status_Color
    },
    GetTaskTime(record,valnames){
      let splits=valnames.split(',')
      let bvalue=record;
      for (let index = 0; index < splits.length; index++) {
        let element = splits[index];
        if(element){
          if(bvalue){
            bvalue=bvalue[element]
          }
          else{
            break;
          }
        }
        
      }
      return this.GetTime(bvalue)
    },
    orgSelectChange(value){
      this.detail_form.name=""
      this.GetUser(value,this.role)
      this.$forceUpdate()
    },
    roleSelectChange(value){
      this.detail_form.name=""
      this.GetUser(this.org,value)
      this.$forceUpdate()
    },
    NameSelectChange(){
      this.searchTaskDetails(1);
    },
    workSelectChange(){
      this.searchTaskDetails(1);
    },
    detail_status_change(){
      this.searchTaskDetails(1);
    },





    searchTaskDetails(pagenum=1){
      this.taskdetals_show_simple_data=[]
      let qs={
        pagesize:this.taskdetals_show_simple_pagination.pageSize,
        pagenum,
        mergeid:this.mergeid,
        work_type:this.work_type,
        optype:this.manager_task_type
      }
      let status=this.detail_form.status===""?-3:this.detail_form.status-0
      if(status>=-2){
        qs.status=status
      }
      if(this.detail_form.code!=""){
        qs.code=this.detail_form.code
      }
      if(this.detail_form.name !=""){
        qs.name=this.detail_form.name
      }
      if(this.detail_form.taskid !=""){
        qs.taskid=this.detail_form.taskid
      }
      this.$common_apis.axios_get("/search?",qs)
      .then(res => {
        if(res ){
          let task_one_table_data=res.data
          task_one_table_data.forEach((_featrue,index)=>{
            _featrue.key=index
          })
          this.taskdetals_show_simple_data=task_one_table_data
          this.taskdetals_show_simple_pagination.total=res.page.count
        }
      });
    },
    taskdetals_show_simple_pagination_change(pagination){
      this.taskdetals_show_simple_selectedRowKeys=[]
      this.searchTaskDetails(pagination.current)
      this.taskdetals_show_simple_pagination.ucurrent=pagination.current
    },
    taskdetals_show_simple_selectkeys_change(selectedRowKeys){
      this.taskdetals_show_simple_selectedRowKeys = selectedRowKeys;
    },
    Get_taskdetals_status_color(){
      let status_Color="";
      if(status==-2){
        status_Color="gray"
      }
      else if(status==-1){
        status_Color="red"
      }
      else {
        status_Color="green"
      }
      return status_Color
    },
    Get_taskdetals_status_color_status(record,work){
      let status=record.properties[this.manager_task_type][work].status
      let status_index=this.$store.state.detail_status.findIndex((_detail_status)=>{
        if(_detail_status.status){
          return _detail_status.status==status
        }
        else if(_detail_status.code){
          return _detail_status.code==status
        }
      })
      return status_index>=0?this.$store.state.detail_status[status_index].name:""
    },
    Get_taskdetals_status_check_color(status){
      let status_Color="";
      if(status==2){
        status_Color="red"
      }
      else if(status==1){
        status_Color="green"
      }
      else {
        status_Color="gray"
      }
      return status_Color
    },
    Get_taskdetals_status_edit_color(status){
      return status==2?"green":"gray"
    },
    handleView(imgsrc,a,b,c) {
      this.pic_imgsrc = imgsrc;
      this.pic_view_visible = true;
      this.pic_name=`预览图片:${c}`
    },
    ShowModel(record){
      this.map_visible=true
      let status=record?.properties[this.$store.state.type_name]?.status
      let Drawer_title=""
      if(status==-2){
        Drawer_title="未分配"
      }
      else if(status==-1){
        Drawer_title=`已分配给:${record?.properties[this.$store.state.type_name]?.name},但是未开始判别`
      }
      else if(status==0){
        Drawer_title=`undefind`
      }
      else if(status==1){
        Drawer_title=`已分配给:${record?.properties[this.$store.state.type_name]?.name},判别结果:未符合执法要求的变化图斑`
      }
      else if(status==2){
        Drawer_title=`已分配给:${record?.properties[this.$store.state.type_name]?.name},判别结果:变化图斑`
      }
      else if(status==3){
        Drawer_title=`已分配给:${record?.properties[this.$store.state.type_name]?.name},判别结果:变化图斑->大数据筛查内业合法变化图斑`
      }
      else if(status==4){
        Drawer_title=`已分配给:${record?.properties[this.$store.state.type_name]?.name},判别结果:变化图斑->大数据筛查外业自查未变化图斑`
      }
      else if(status==5){
        Drawer_title=`已分配给:${record?.properties[this.$store.state.type_name]?.name},判别结果:变化图斑->大数据筛查外业自查疑似违法图斑`
      }
      else if(status==6){
        Drawer_title=`已分配给:${record?.properties[this.$store.state.type_name]?.name},判别结果:变化图斑->疑似违法图斑属性已赋值->${record?.properties[this.$store.state.type_name]?.fuzhi.status},`
      }
      else if(status==99){
        Drawer_title=`未定(代号?)`
      }
      this.drawer_title=Drawer_title;
      setTimeout(()=>{
        this.$mitt.emit('set_img_Featrue',record);
      },200)
    },
    closeModel() {
      this.map_visible = false;
    },
    //操作task_show_simple
    set_task_show_simple_status(record){
      this.$mitt.emit("set_status",{
        type:"task_show_simple",
        val:record[this.manager_task_type]?.status,
        other:record.mergeid
      })
    },
    set_task_show_simple_status_back(vals){
      this.$common_apis.axios_post("/update_task?",{
        mergeid:vals.other,
        status:vals.val,
        stime:new Date().getTime(),
        optype: this.manager_task_type
      },true).then(() => {
        this.searchTask(this.task_show_simple_pagination.ucurrent);
        this.$message.success(`任务状态${vals.other}更新成功`)
      });
    },
    task_show_simple_delete(record){
      console.log(`will delete the ${record.mergeid}...  `)
    },
    FenPei(record){
      this.can_fenpei=true
      this.showFenPei=true;
      this.mergeid=record.mergeid
      this.ClickSearch()
    },
    single_fenpei(mongoid,jvbh){
      this.fenpei_fun({
        values:[{
          id:mongoid,
          jvbh
        }],
        activeUsers:this.$store.state.users
      })
    },
    mulity_fenpei(){
       if(this.taskdetals_show_simple_selectedRowKeys.length==0){
        this.$message.info('没有选择图斑，至少需要选择一个');
        return false
      }
      let codes=[]
      this.taskdetals_show_simple_selectedRowKeys.forEach((_featrue,index)=>{
        codes.push({
          id:this.taskdetals_show_simple_data[_featrue]['_id'],
          jvbh:this.taskdetals_show_simple_data[_featrue].properties.other.JVBH,
          taskid:this.taskdetals_show_simple_data[_featrue].properties.taskid,
        })
      })
      this.fenpei_fun({
        values:codes,
        activeUsers:this.$store.state.users
      })
    },
    input_fenpei(){
      this.fenpei_fun({
        activeUsers:this.$store.state.users
      },"input")
    },
    fenpei_fun(optinos,type="select"){
      optinos.type=type
      this.$mitt.emit("fenpei_to_user",optinos)
    },
    async fenpei_update(vals){
      let data={
        mergeid:this.mergeid,
        name:vals.user,
        work_type:this.work_type,
        optype: this.manager_task_type,
      }
      if(vals.type=="input"){
        data.from=vals.num_from
        data.to=vals.num_to
        if(this.detail_form.status>=-2){
          data.status=this.detail_form.status-0
        }
      }
      else if(vals.type=="select"){
        let codes=[]
        vals.values.forEach((_featrue,index)=>{
          codes.push(_featrue.id)
        })
        data.ids=codes.join(',')
      }
      let result=await this.$common_apis.axios_post("/update_admin?",data,true)
      if(result){
        this.searchTaskDetails(this.taskdetals_show_simple_pagination.ucurrent);
      }
    },






    StartTask(taskid){
      this.$common_apis.axios_post("/update_task?",{
          mergeid:taskid,
          status:0,
          stime:new Date().getTime(),
          optype: this.manager_task_type
        },true).then(() => {
          this.search();
          this.$message.success(`开始任务${taskid}成功`)
        });
    },
    EndTask(taskid){
      this.$common_apis.axios_post("/update_task?",{
        mergeid:taskid,
        status:1,
        etime:new Date().getTime(),
        optype: this.manager_task_type
      },true).then(() => {
        this.search();
        this.$message.success(`结束任务${taskid}成功`)
      });
    },
    DeleteTask(taskid){
      this.$common_apis.axios_post("/delete_task?",{
        mergeid:taskid,
      }).then(() => {
        this.search();
        this.$message.success(`删除任务${taskid}成功`)
      });
    },
    PropTask(taskid){
      this.$common_apis.axios_post("/update_task?",{
        mergeid:taskid,
        status:2,
        stime:new Date().getTime(),
        optype: this.manager_task_type
      },true).then(() => {
        this.search();
        this.$message.success(`属性分类任务${taskid}添加成功`)
      });
    },
    QuanZhongTask(taskid){
      this.$common_apis.axios_post("/update_task?",{
        mergeid:taskid,
        status:2,
        stime:new Date().getTime(),
        optype: this.manager_task_type
      },true).then(() => {
        this.search();
        this.$message.success(`属性分类任务${taskid}添加成功`)
      });
    },
    DownTask(taskid){
      this.$mitt.emit('task_manager_show',4);
      this.$mitt.emit('task_manager_download_taskid',taskid);
    },
    
    async search_process(){
      let _finds=this.$store.state.detail_status.filter((_detail_status)=>{
        return _detail_status.status>=0
      })
      let _statusNeed=[]
      _finds.forEach((_find)=>{
        _statusNeed.push(_find.status)
      })
      for(let i=0;i <this.table_data.length;i++){
        let qs={
          optype:this.manager_task_type,
          pagesize:1,
          pagenum:1,
          onlyid:"true",
          mergeid:this.table_data[i].mergeid,
          status:_statusNeed.join(',')//"0,1,2,3,4,5"
        }
        let result=await this.$common_apis.axios_get("/search?",qs)
        if(result){
          this.table_data[i].process=parseInt(result.page.count/result.page.countAll*100)
          this.table_data[i].num=result.page.countAll
        }
        else{
          this.table_data[i].process=0
        }
      }
      this.$forceUpdate()
    },
    CheckType(mergeid,status){
      this.$common_apis.axios_post("/check_type?",{
        mergeid:mergeid,
        check_type:status,
        optype: this.manager_task_type
      },true).then(() => {
        this.$message.success(`CheckType任务${mergeid}添加成功`)
      });
      console.log(mergeid,status)
    },
    checker_back_to_amqp(mergeid,status){
      this.$common_apis.axios_post("/checker_back_to_amqp?",{
        mergeid:mergeid,
        check_type:status,
        optype: this.manager_task_type
      },true).then(() => {
        this.$message.success(`未完成任务${mergeid}重新返回队列添加成功`)
      });
    },
    tooltip_visibleChange(visible,mergeid,status){
      console.log("tooltip_visibleChange",visible,mergeid,status)
    },
    CheckType_fuzhi_over(mergeid,status){
      this.amqp_num=0
      this.amqp_task_num=0
      this.$common_apis.axios_get("/get_check_remain?",{
        mergeid:mergeid,
        check_type:status,
        optype: this.manager_task_type
      },true).then(result => {
        this.amqp_num=result.remain
        this.amqp_task_num=result.count
      });
    },
    CheckType_fuzhi_out(){
      console.log("CheckType_fuzhi_out")
    },
    dropdown_click(e){
      // console.log("dropdown_click")
      e.preventDefault()
    },
    tooltip_click(){
      console.log("tooltip_click")
    },
    re_publish_cog(mergeid){
      this.$common_apis.axios_get("/re_publish_cog?",{
        mergeid:mergeid,
      },true)
    },
   
  },
}
</script>